package me.jzn.alib.beans;


import me.jzn.core.exceptions.UnableToRunHereException;

@Deprecated
public final class Pwd {
    public final PwdType type;
    public final String value;
    public Pwd(String value) {
        this.type = PwdType.TXT;
        this.value = value;
    }

    public Pwd(PwdType type, String value) {
        this.type = type;
        this.value = value;
    }
    public static Pwd fromString(String str) {
        int splitIdx = str.indexOf(':');
        if (splitIdx < 0) {
            throw new UnableToRunHereException("acc必须包含分隔符");
        }
        PwdType type = PwdType.valueOf(str.substring(0, splitIdx));
        String value = str.substring(splitIdx + 1);
        return new Pwd(type, value);
    }
    public String asString() {
        return type + ":" + value;
    }

    @Override
    public String toString() {
        return type + ":" + value;
    }

    /**
     * 支持文字和手势2种
     */
    public static enum PwdType {
        TXT, PTN
    }
}
